package com.DuoXianCheng.T01;

public class C01 extends Thread{
    static int count = 1000;
    
    static Object lock = new Object();
    @Override
    public void run() {
        while (true) {
            synchronized (lock) {
                if(count == 0){
                    break;
                } else {
                    try {
                        Thread.sleep(3);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    count--;
                    System.out.println(Thread.currentThread().getName() + "卖出一张，还剩" + count + "张");
                }
            }
        }
    }
}
